<%@ page language="java" import="java.util.*,com.xiaobin.system.util.*" pageEncoding="UTF-8"%>
<%@ include file="/base/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>${systemOption.systemTitle}</title>
    <%@ include file="/base/head.jsp"%>
    <script language="javascript" src="${ctx}/js/LodopFuncs.js"></script>
    <script type="text/javascript" charset="UTF-8">
		//分页查询
	function doQuery() {
		var queryParams = $('#msgList').datagrid('options').queryParams;
		queryParams.fromtime = $('#searchfromTime').datebox('getValue');
		queryParams.totime = $('#searchtoTime').datebox('getValue');
		queryParams.subject = $('#searchSub').val();
		queryParams.SName = $('#searchName').val();
		//重置当前页数为1
		resetDG('#msgList');
	}
 	//删除
	function del_msg() {
		var slt=$('#msgList').datagrid('getSelected');
		if (!slt) {
			$.messager.alert('友情提示', '请选择消息', 'error');
		} else {
			$.messager.confirm('友情提示', '将删除该消息，确定么？', function(r) {
				if(r){
			       $.post("${ctx}/msg/deleteRMsg.action", {"ids": slt.id },
					 function(data) {
						if (data.success) {
							$.messager.alert('友情提示', '删除成功', 'info');
							$('#msgList').datagrid('reload');
						} else {
							$.messager.alert('友情提示', '删除失败', 'error');
						}
					}, "json");
				}
			});

		}
	}

	//详情
 function detail(){
 	var row = $('#msgList').datagrid('getSelected');
 	document.getElementById('sendtime').innerHTML = row.sendtimestr;
 	document.getElementById('sname').innerHTML = row.sname;
 	document.getElementById('subject').innerHTML = row.subject;
 	document.getElementById('content').innerHTML = row.content;		     
 	$('#xqdlg').show();	
 	$('#xqdlg').dialog({
 		title: '详情',   
	    width: 750,
	    height:400,
	    top:50,
	    closed : false,
		cache : false,
		maximizable : true,
		collapsible : false,
		minimizable : false,
	    cache: false, 
	    modal: true,
	    buttons:[{
	    	text:'关闭',
			iconCls:'icon-cancel',
			handler:function(){
				$('#xqdlg').dialog('close');
			}	    	
	    }]
 	});	
 }
	</script>

  </head>
  
  <body>

        <!-- 主窗口 -->  	 
  	  <table id="msgList" class="easyui-datagrid" data-options="fit:true,
	    								rownumbers:true,
										singleSelect:true,
										striped:true,
										fitColumns:true,
										border:false,
										toolbar:'#tb',
										pagination:true,
										pageSize:20,
										nowrap:true,
										url:'${ctx}/msg/listRMsg.action',
										onDblClickRow:detail">
			<thead>
				<tr>
					<th data-options="field:'ck',checkbox:true"></th>
					<th data-options="field:'sname',align:'left'" width="400px"><strong>发送人</strong></th>
					<th data-options="field:'subject',align:'left'" width="500px"><strong>主题</strong></th>
					<th data-options="field:'sendtimestr',align:'center'" width="150px"><strong>发送时间</strong></th>
					<th data-options="field:'id',hidden:true"></th>
				</tr>
			</thead>
		</table>
		<!-- Datagrid工具栏 -->
		<div id="tb">
			<table width="100%" cellpadding="0" cellspacing="0">
				<tr>
			   		<td class="toolDiv">  		
			  			<a href="javascript:void(0)" onclick="del_msg()" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true" style="float:left;">删除</a><div class="datagrid-btn-separator"> </div>
					</td>
				</tr>
				<tr>
					<td class="serchDiv">
						发送人：<input id="searchName" class="easyui-validatebox" type="text"  style="width:200px">
						&nbsp;&nbsp; 主题：<input id="searchSub" class="easyui-validatebox" type="text"  style="width:200px">
						&nbsp;&nbsp; 发送时间：
						<input id="searchfromTime" class="easyui-datebox" />至<input id="searchtoTime" class="easyui-datebox"/>
						&nbsp;&nbsp;<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" 
										onclick="doQuery()">查询</a>
					</td>
				</tr>
			</table>
		</div>
		<!-- 详情窗口 -->    
		<div id="xqdlg" style="display: none">
<table class="dlgtb" cellpadding="0" cellspacing="0" width="100%">
		<tr height="30px"> 
			<td width="50px;" align="center" class="lbl1">
				发送人
			</td>
			<td  id ="sname"width="100px">
				
			</td>
			<td width="80px;" align="center" class="lbl1">
				发送时间
			</td>
			<td id = "sendtime" width="100px;">
				
			</td>
		</tr>
		<tr height="50px">
			<td align="center" class="lbl1" width="30px">
				主题
			</td>
			<td id = "subject" colspan="3" width="80px">
				
			</td>
		</tr>
		<tr>
			<td id = "content" colspan="4" style="border: 0px;">
			
			</td>
		</tr>
	</table>
		</div>
  </body>
</html>
